//package com.vcg.community.service.impl;
//
//import com.alibaba.fastjson.JSONObject;
//import com.amazonaws.auth.AWSCredentialsProvider;
//import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
//import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
//import com.vcg.community.beans.*;
//import Service;
//import SpringUtils;
//
///**
// * @author fyq on
// * @created by 2016/6/6
// */
//public class ServiceImpl implements Service {
//
//    public DynamoDBMapper dynamoDBMapper;
//
//    public AmazonDynamoDBClient dynamoDBClient;
//
//    public final String dynamodbEndpoint = "dynamodb.ap-northeast-1.amazonaws.com";
//
//    public AWSCredentialsProvider credentialsProvider;
//
//    public ServiceImpl(){
//        try {
//            dynamoDBMapper = SpringUtils.getBean("dynamoDBMapper");
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        try {
//            dynamoDBClient = SpringUtils.getBean("dynamoDBClient");
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//    public BaseEntity get(JSONObject jsonObject){
//        String itemType = jsonObject.getString("itemType");
//        JSONObject json = new JSONObject();
//        for(String key : jsonObject.keySet()) {
//            String newKey = null;
//            if(key.contains("_")) {
//                String[] keys = key.split("_");
//                String jsonKey = null;
//                for (int i = 0; i < keys.length; i++) {
//                    if (i == 0) {
//                        jsonKey = keys[i];
//                    } else {
//                        String first = keys[i].substring(0, 1).toUpperCase();
//                        String rest = keys[i].substring(1, keys[i].length()).toLowerCase();
//                        jsonKey += first + rest;
//                    }
//                }
//                newKey = jsonKey;
//            } else {
//                newKey = key;
//            }
//            json.put(newKey, jsonObject.get(key));
//        }
//        if(itemType.equals("user")) {
//            return JSONObject.toJavaObject(json, UserEntity.class);
//        } else if(itemType.equals("photo")) {
//            return JSONObject.toJavaObject(json, PhotoEntity.class);
//        } else if(itemType.equals("gallery")) {
//            return JSONObject.toJavaObject(json, GalleryEntity.class);
//        } else if(itemType.equals("like")) {
//            return JSONObject.toJavaObject(json, LikeEntity.class);
//        } else if(itemType.equals("follow")) {
//            return JSONObject.toJavaObject(json, FollowEntity.class);
//        }
//        return null;
//    }
//
//    public void save(BaseEntity t) {
//        if(t.getItemType().equals("user")) {
//
//        }
//        dynamoDBMapper.save(t);
//    }
//
//}
